﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using BibliotecaClases;

namespace Parque
{
    public partial class FAtracciones : Form
    {
        public ENAtracciones atraccion;

        public FAtracciones()
        {
            atraccion = new ENAtracciones();
            InitializeComponent();
        }

        private void FAtracciones_Load(object sender, EventArgs e)
        {

        }

        private void BTExaminar_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "jpg (*.jpg)|*.JPG|*.* (todo)|*.*";
            openFileDialog1.InitialDirectory="C:\\users\\joan\\pictures";
            PBFoto.SizeMode = PictureBoxSizeMode.StretchImage;
            openFileDialog1.ShowDialog();
            PBFoto.ImageLocation = openFileDialog1.FileName.ToString();
            PBFoto.Show();
        }

        private void PBFoto_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.Filter = "jpg (*.jpg)|*.jpg";
            openFileDialog1.InitialDirectory = "C:\\users\\joan\\pictures";
            PBFoto.SizeMode = PictureBoxSizeMode.StretchImage;
            openFileDialog1.ShowDialog();
            PBFoto.ImageLocation = openFileDialog1.FileName.ToString();
            PBFoto.Show();
        }

        private void BTGuardar_Click_1(object sender, EventArgs e)
        {
            ClaseValidacion validar = new ClaseValidacion();
            bool errorGuardar = false;

            if (TBNombre.Text == "")
            {
                errorNombre.SetError(TBNombre, "Campo Obligatorio");
                errorGuardar = true;
            }
            else
                errorNombre.Clear();


            if (CBBZona.Text == "")
            {
                errorZona.SetError(CBBZona, "Campo Obligatorio");
                errorGuardar = true;
            }
            else
                errorZona.Clear();


            if (NUDVidaUtil.Value == 0)
            {
                errorVidaUtil.SetError(NUDVidaUtil, "Campo Obligatorio");
                errorGuardar = true;
            }
            else
                errorVidaUtil.Clear();


            if (NUDRevision.Value == 0)
            {
                errorRevision.SetError(NUDRevision, "Campo Obligatorio");
                errorGuardar = true;
            }
            else
                errorRevision.Clear();

            
            if (!errorGuardar)
                MessageBox.Show("Rellene los campos obligatorios");
            
        }
        public void Interfaz(int i)
        {
            string path;
            ////////     ESTO ES EL FONDO Y LOS BOTONES DE LA IZQUIERDA
            path = "C:\\bd\\fondo" + i + ".jpg";
            this.BackgroundImage = Image.FromFile(path);

            path = "C:\\bd\\colores\\nuevo" + i + ".png";
            BTGuardar.BackgroundImage = Image.FromFile(path);
            BTGuardar.BackgroundImageLayout = ImageLayout.Stretch;

            path = "C:\\bd\\colores\\modificar" + i + ".png";
            BTModificar.BackgroundImage = Image.FromFile(path);
            BTModificar.BackgroundImageLayout = ImageLayout.Stretch;

            path = "C:\\bd\\colores\\buscar" + i + ".png";
            BTBuscar.BackgroundImage = Image.FromFile(path);
            BTBuscar.BackgroundImageLayout = ImageLayout.Stretch;

            path = "C:\\bd\\colores\\eliminar" + i + ".png";
            BTEliminar.BackgroundImage = Image.FromFile(path);
            BTEliminar.BackgroundImageLayout = ImageLayout.Stretch;

            ////////    A PARTIR DE AQUI ELEGIMOS LOS COLORES SEGUN LA INTERFAZ ELEGIDA
            if (i == 2)
            {
                TBNombre.BackColor = Color.Khaki;
                TBNombre.ForeColor = Color.Blue;

                CBBZona.BackColor = Color.Khaki;
                CBBZona.ForeColor = Color.Blue;

                NUDVidaUtil.BackColor = Color.Khaki;
                NUDVidaUtil.ForeColor = Color.Blue;

                NUDRevision.BackColor = Color.Khaki;
                NUDRevision.ForeColor = Color.Blue;

                CBBPublico.BackColor = Color.Khaki;
                CBBPublico.ForeColor = Color.Blue;

                CBBAlturaMin.BackColor = Color.Khaki;
                CBBAlturaMin.ForeColor = Color.Blue;

                RTBDescripcion.BackColor = Color.Khaki;
                RTBDescripcion.ForeColor = Color.Blue;

                DGVAtracciones.BackgroundColor = Color.Khaki;
                DGVAtracciones.ForeColor = Color.Blue;


            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Realmente desea cerrar la aplicación?", "Cerrar aplicación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
            {
                Application.Exit();
            }
        }
        
    }
}
